package com.liusand.movement.controller;

import com.liusand.entity.dto.MovementDto;
import com.liusand.entity.vo.MovementVo;
import com.liusand.entity.vo.PageInfo;
import com.liusand.entity.vo.Result;
import com.liusand.movement.service.MovementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author :liusha
 * packageName :com.liusand.movement.controller
 * fileName :MovementController
 * creationTime :2022/12/23 15:13
 */
@RestController
@RequestMapping("/movement")
public class MovementController {

    @Autowired
    private MovementService movementService;

    @PostMapping
    public Result addMovement(MovementDto movementDto){
        boolean result = movementService.addMovement(movementDto);
        if(!result){
            return Result.error("添加失败");
        }
        return Result.success();
    }

    @GetMapping
    public Result getMovement(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "10") Integer pageSize){
        PageInfo<MovementVo> pageInfo = movementService.getMovement(page, pageSize);
        return Result.success(pageInfo);
    }
}
